<?php
class Somi_Form_Kontakt extends Zend_Dojo_Form
{
	public function init()
	{
		
		$this->setName('Kontakt');
		$this->setAction($this->getView()->url())->setMethod('post');
		$this->addAttribs(array('onSubmit'=>'return validate(this)'));
		
		require_once APPLICATION_HTDOCS.'/library/Somi/Validate/ErrorMessageDe.php';
		
		$translateValidators= new Somi_Validate_ErrorMessageDe();
		$translator = new Zend_Translate('array', $translateValidators->getTranslate());
    	Zend_Validate_Abstract::setDefaultTranslator($translator);
    	
    	#$this->clearDecorators();
		$formDecorators=array(
            'FormElements',
        array('HtmlTag',array('tag'=>'dl','class'=>'zend_form')),
            'DijitForm', // hier stand bei dir vorher: 'Form',
        );
                
        
        $elementDecorators=array(
        array('DijitElement'), // vorher: 'ViewHelper',
        array('Errors'),
        array(array('data'=>'HtmlTag'),array('tag'=>'div','class'=>'element')),
        array('Label',array('class'=>'left','requiredSuffix' => '*')),
        array(array('row'=>'HtmlTag'),array('tag'=>'div','class'=>'row')),
        );
        
        $buttonDecorators=array(
        'DijitElement', // vorher: 'ViewHelper',
        array(array('data'=>'HtmlTag'),array('tag'=>'div','class'=>'button')),
        array(array('row'=>'HtmlTag'),array('tag'=>'div'))
        );  
		
	
		$filterToLower = new Zend_Filter_StringToLower();
        $filterToLower->setEncoding('UTF-8');
        

        
        #Firma
        $firma=$this->createElement('ValidationTextBox','firma',array(
        'label'			=> 'Firma',
        'alnum'			=>true,
        'required'		=> false,
        'PromptMessage'		=> '<div style="width:200px">z.B. SOMI Solutions GmbH</div>', 
        'style'			=> 'width:245px;', 
        'filters'		=> array($filterToLower,),
        #'validators'	=> array('NotEmpty',), 
        ));
	     
	     
        
	    #Anrede
        $anrede = $this->createElement('FilteringSelect','anrede',array(
		'label'        => 'Anrede',
        'value'        => '',
        'autocomplete' => false,
        'style'			=> 'width:245px;',
        'multiOptions' => array('Frau' => 'Frau','Herr' => 'Herr'),
        ));

        
        #Vorname
        $vorname=$this->createElement('ValidationTextBox','vorname',array(
        'label'			=> 'Vorname',
        'alnum'			=>true,
        'required'		=> false,
        'PromptMessage'		=> '<div style="width:200px">z.B. Max</div>', 
        'style'			=> 'width:245px;', 
        'filters'		=> array($filterToLower,),
        #'validators'	=> array('NotEmpty',), 
        ));
        
        
        #name
        $nachname=$this->createElement('ValidationTextBox','nachname',array(
        'label'			=> 'Nachname *',
        'alnum'			=>true,
        'required'		=> true,
        'PromptMessage'		=> '<div style="width:200px">z.B. Müller</div>', 
        'style'			=> 'width:245px;', 
        'filters'		=> array($filterToLower,),
        'validators'	=> array('NotEmpty',), 
        ));
        
		$validateEmail = new Zend_Validate_EmailAddress();
        #Email
        $email=$this->createElement('ValidationTextBox','email',array(
        'label'			=> 'Email *',
        'alnum'			=>true,
        'required'		=> true,
        'PromptMessage'	=> '<div style="width:200px">z.B. inf@somi.de </div>', 
        'style'			=> 'width:245px;', 
        'filters'		=> array($filterToLower,),
        'validators'	=> array('NotEmpty',$validateEmail,),
        #'regExp'			=>'\b[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}\b', 
        ));
        
        
        #Telefon
        $telefon=$this->createElement('ValidationTextBox','telefon',array(
        'label'			=> 'Telefon',
        'alnum'			=>true,
        'required'		=> false,
        'PromptMessage'		=> '<div style="width:200px">z.B. 06957706700 oder<br> 0049125456789 </div>', 
        'style'			=> 'width:245px;', 
        #'regExp'			=>'\(?[0][0-9]+\)?([-. ]?[0-9])*$~i',
        'regExp'		=> '(^[0+]{1})([ 0-9/()]+$)', 
        #'validators'		=> array('NotEmpty',array('Regex',true,array('^0[0123456789]{1}[\s]{0,1}[\-]{0,1}[\s]{0,1}[1-9]{1}[0-9]{15}$'))),
        ));

        
        
        #Nachricht
		$nachricht=$this->createElement('Textarea','nachricht',array(
		'label'		=> 'Nachricht *',
		#'style'		=>'height:100px;width:300px;',
		#'height'		=>'100px',
		#'PromptMessage'		=> '<div style="width:200px">Noch mher Input</div>',
		'style'    => 'width: 248px; height: 100px;',
		'required'	=> true,
		'validators'	=> array('NotEmpty',),
		));       
        
        
        $submit=$this->createElement('SubmitButton','submit',array(
        'label'			=> 'Senden',
        'style'			=> 'margin-left:345px;',
        ));
        
        
        
        $this->addElements(array($firma,$anrede,$vorname,$nachname,$email,$telefon,$nachricht,$submit));
        
	}
}